zynqmp: pm: Implement PLL get parameter EEMI API
authorJolly Shah <[email protected]>
Fri, 4 Jan 2019 19:28:38 +0000 (11:28 -0800)
committerJolly Shah <[email protected]>
Fri, 4 Jan 2019 19:30:31 +0000 (11:30 -0800)
This API will be used to get a parameter for the PLL. Parameter values
represent the values as defined in the Zynq MPSoC register reference
manual ug1087.

Signed-off-by: Mirela Simonovic <[email protected]>
Acked-by: Will Wong <[email protected]>
Signed-off-by: Jolly Shah <[email protected]>
plat/xilinx/zynqmp/pm_service/pm_api_sys.c
plat/xilinx/zynqmp/pm_service/pm_api_sys.h
plat/xilinx/zynqmp/pm_service/pm_defs.h
plat/xilinx/zynqmp/pm_service/pm_svc_main.c

index 9bc11f26b34c43cd87b64e5fa46ddeb729b516ee..da1669114ec038ef09b339a8b3471bfd8aca967e 100644 (file)
@@ -1268,3 +1268,31 @@ enum pm_ret_status pm_pll_set_parameter(enum pm_node_id nid,
        PM_PACK_PAYLOAD4(payload, PM_PLL_SET_PARAMETER, nid, param_id, value);
        return pm_ipi_send_sync(primary_proc, payload, NULL, 0);
 }
+
+/**
+ * pm_pll_get_parameter() - Get the PLL parameter value
+ * @nid                Node id of the target PLL
+ * @param_id   ID of the PLL parameter
+ * @value      Location to store the parameter value
+ *
+ * @return     Error if an argument is not valid or status as returned by the
+ *             PM controller (PMU)
+ */
+enum pm_ret_status pm_pll_get_parameter(enum pm_node_id nid,
+                                       enum pm_pll_param param_id,
+                                       unsigned int *value)
+{
+       uint32_t payload[PAYLOAD_ARG_CNT];
+
+       /* Check if given node ID is a PLL node */
+       if (nid < NODE_APLL || nid > NODE_IOPLL)
+               return PM_RET_ERROR_ARGS;
+
+       /* Check if parameter ID is valid and return an error if it's not */
+       if (param_id >= PM_PLL_PARAM_MAX)
+               return PM_RET_ERROR_ARGS;
+
+       /* Send request to the PMU */
+       PM_PACK_PAYLOAD3(payload, PM_PLL_GET_PARAMETER, nid, param_id);
+       return pm_ipi_send_sync(primary_proc, payload, value, 1);
+}
index acef4906c9a7d5571f30ace1075624cdde342e3e..8ef210ac028804e9fcd07a64a565c8526cabe1c6 100644 (file)
@@ -180,4 +180,8 @@ enum pm_ret_status pm_pll_set_parameter(enum pm_node_id nid,
                                enum pm_pll_param param_id,
                                unsigned int value);
 
+enum pm_ret_status pm_pll_get_parameter(enum pm_node_id nid,
+                               enum pm_pll_param param_id,
+                               unsigned int *value);
+
 #endif /* PM_API_SYS_H */
index fe965c5396e984391a554151ab0563cd865806cb..167a73331b57a2a975d83e3f5975de3e52c7b406 100644 (file)
@@ -94,6 +94,7 @@ enum pm_api_id {
        PM_SECURE_AES,
        /* PLL control API functions */
        PM_PLL_SET_PARAMETER,
+       PM_PLL_GET_PARAMETER,
        PM_API_MAX
 };
 
index 7430110039436f23b56c24c4ec8194de318c1d85..4e4a3ef6d169680b10235032a5ee5d4dfdb3f77a 100644 (file)
@@ -567,6 +567,14 @@ uint64_t pm_smc_handler(uint32_t smc_fid, uint64_t x1, uint64_t x2, uint64_t x3,
                ret = pm_pll_set_parameter(pm_arg[0], pm_arg[1], pm_arg[2]);
                SMC_RET1(handle, (uint64_t)ret);
 
+       case PM_PLL_GET_PARAMETER:
+       {
+               uint32_t value;
+
+               ret = pm_pll_get_parameter(pm_arg[0], pm_arg[1], &value);
+               SMC_RET1(handle, (uint64_t)ret | ((uint64_t)value << 32));
+       }
+
        default:
                WARN("Unimplemented PM Service Call: 0x%x\n", smc_fid);
                SMC_RET1(handle, SMC_UNK);